
#include<stdio.h>

int main()
{
	int m, n;
	scanf("%d%d", &m, &n);
	int arr[101][101] = {0};
	int i, j;
	for (i = 0; i < m; i++)
	{
		for (j = 0; j < n; j++)
		{
			scanf("%d", &arr[i][j]);
		}
	}
	
	for (i = 0; i < m; i++)
	{
		int end, len, max;
		end = len = max = 0;
		int flag = 0;
		for (j = 0; j < n; j++)
		{
			if (arr[i][j] == 1)
			{
				flag = 1;
				len++;
				if (arr[i][j+1] == 0)
				{
					if (max < len)
					{
						max = len;
						len = 0;
						end = j;
					}
				}
			}
		}
		if (flag)
			printf("%d %d\n", end-max+1, end);
		else
			printf("-1 -1\n");
	}
		
	return 0;
}


